home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 April: Mac OS SDK / Dev.CD Apr 99 SDK1.toast / Development Kits / Mac OS USB DDK / Examples / PrinterClassDriver / DRVRGlue.a < prev    next >
Encoding:
Text File  |  1999-02-10  |  2.8 KB  |  106 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        DRVRGlue.a
  3. ;
  4. ;    Contains:    DRVR interface
  5.  
  6. ;
  7. ;    Copyright:     1998 by Apple Computer, Inc., all rights reserved.
  8. ;
  9. ;    Change History:
  10. ;
  11. ;        27 Jul 98    oja        VMImmuneMask not set so that we HoldMemory on io buffers, param blocks
  12. ;        24 Apr 98    oja        DrvrDone takes an error, passes on to JIODone
  13. ;        26 Mar 98    oja        changed driver name to ".USB--Print___"
  14. ;        28 Feb 98    oja        loosely based on Apple's StyleWriter DRVR
  15. ;
  16. ;    To Do:
  17. ;
  18.  
  19.         
  20.     BLANKS    ON
  21.     STRING    ASIS
  22.         
  23.     INCLUDE        'LowMem.a'
  24.     INCLUDE        'Devices.a'
  25. ;
  26. ;    for an explanation of VMimmune and gestalt see AsyncDriverSample 1.0b4
  27. ;
  28. dVMImmuneMask                EQU    $0001
  29. dDriverGestaltEnableMask    EQU    $0004    ; See DriverGestalt.h
  30.  
  31. drvrFlags        EQU    dReadEnableMask +  dWritEnableMask + dCtlEnableMask +  dStatEnableMask
  32. drvrSystemFlags    EQU dNeedLockMask
  33.  
  34. DRVREntry        MAIN    EXPORT
  35.  
  36.                 IMPORT    DRVROpen, DRVRPrime, DRVRControl, DRVRStatus, DRVRClose
  37.  
  38. Header
  39.         dc.w    drvrFlags + drvrSystemFlags
  40.         DC.W    0        ; no run time
  41.         DC.W    0        ; no events
  42.         DC.W    0        ; no menu
  43.  
  44. ; Entry point offset table to the procs: Open, Prime, Control, Status, Close
  45.         DC.W    MyOpen        - DRVREntry  ; open routine
  46.         DC.W    MyPrime        - DRVREntry  ; prime
  47.         DC.W    MyControl    - DRVREntry  ; control
  48.         DC.W    MyStatus    - DRVREntry  ; status
  49.         DC.W    MyClose        - DRVREntry  ; close
  50.  
  51. ; Title
  52. ;        include three pad bytes so we can re-number the driver
  53.         DC.B    14                    ;Length byte
  54.         DC.B    '.USB--Print---'    ;Pad to odd # of chars, so 1st routine
  55.                                     ;  will be word-aligned.
  56.  
  57. ; Push the address of the routine we wish to call and jump to the glue
  58. ; which sets up the parameters and calls the actual driver implementation
  59. MyOpen        PEA        DRVROpen
  60.             bra.s    MyGlue
  61. MyPrime        PEA        DRVRPrime
  62.             bra.s    MyGlue
  63. MyControl    PEA        DRVRControl
  64.             bra.s    MyGlue
  65. MyStatus    PEA        DRVRStatus
  66.             bra.s    MyGlue
  67. MyClose        PEA        DRVRClose
  68.  
  69. MyGlue
  70.             MOVEM.L    A0/A1,-(A7)                ; save params to the routine
  71.             CLR.W    -(A7)                    ; make room for result
  72.             MOVE.L    A0,-(A7)                ; pass the parameter block
  73.             MOVE.L    A1,-(A7)                ; pass the device control entry
  74.             MOVEA.L    $0012(A7),A0            ; address of routine to jump to
  75.             JSR        (A0)                    ; do it
  76.             MOVE.W    (A7)+,D0                ; get result
  77.             MOVEM.L    (A7)+,A0/A1                ; restore device parameters
  78.             ADDQ.W    #4,A7                    ; pop routine address to clean up
  79. ;            tst.w    IOParam.ioResult(a0)
  80. ;            beq.s    IOComplete
  81.             BTST    #10,IOParam.ioTrap(A0)    ; test for an async call
  82.             BNE.S    Done                    ; if not async, we're done
  83. IOComplete
  84.             SUBQ.W    #4,A7                    ; else get the JIODone vector
  85.             _LMGetJIODone                    ; so we can jump to it.
  86. Done
  87.             RTS        
  88. ;
  89. ;
  90. ;    Change History:
  91. ;        24 Ar 1998,    oja:    pass the error in D0
  92. ;
  93. DRVRDONE    PROC    EXPORT
  94.             
  95.             MOVE.L    4(sp),a0                ; pass the parameter block
  96.             MOVE.L    8(sp),a1                ; pass the device control entry
  97.             MOVE.W    12(sp),d0
  98.             SUBQ.W    #4,A7                    ; get the JIODone vector
  99.             _LMGetJIODone                    ; jump to it.
  100.             
  101.             RTS
  102.  
  103.             ENDPROC
  104.     END
  105.     
  106.